﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace Triples {
    public class PlayableCard : IPlayableCard, INotifyPropertyChanged {

        public event PropertyChangedEventHandler PropertyChanged;

        private bool _IsSelected;
        private bool _IsEnabled;
        private int? _Position;

        public byte Value {
            get;
            set;
        }

        public int? Position {
            get { return _Position; }
            set { Set<int?>(ref _Position, value, "Position"); }
        }

        public bool IsSelected {
            get { return _IsSelected; }
            set { Set<bool>(ref _IsSelected, value, "IsSelected"); }
        }

        public bool IsEnabled {
            get { return _IsEnabled; }
            set { Set<bool>(ref _IsEnabled, value, "IsEnabled"); }
        }

        public Shades Shade {
            get;
            private set;
        }

        public Shapes Shape {
            get;
            private set;
        }

        public Colors Color {
            get;
            private set;
        }

        public Numbers Number {
            get;
            private set;
        }


        public PlayableCard (ICard card) {
            this.Shade = card.Shade;
            this.Shape = card.Shape;
            this.Color = card.Color;
            this.Number = card.Number;
            this.IsEnabled = true;
        }


        private void Set<T>(ref T var, T value, string p) {
            var = value;
            if (null != PropertyChanged) PropertyChanged(this, new PropertyChangedEventArgs(p));
        }

        public override string ToString() {
            return String.Format("{0} {1} {2} {3}", Number, Shape, Color, Shade);
        }
    }
}
